tree grammar Process0Walker;

options {
  language = Java;
  tokenVocab = Process0;
  ASTLabelType = CommonTree;
}
@header {
  package process0.gen;
}

process returns[String out]
  : {out = "";}
  ^(
    IDENT {out= out + "[" +$IDENT.text + "]";} 
    (
      w = workflow {out = out + w;}
    )* 
   )
   {return out;}
  ;


workflow returns [String out]
  : {out = "";}
    ^(
      'workflow'
      IDENT{out = "\n" + $IDENT.text;} 
      (
        a=action {out = out + a;}
      )+
     )
     {return out;}
  ;

action returns [String out]
  :{out = "";}
    ^(
      IDENT 
      (
        s = states { out = out + "\n" + $IDENT.text + s;}
      )+
     ) {return out;}
  ;
  
states returns [String out]
  :{out = " =";}
    ^(
      e = IDENT  
      b1=IDENT {out = out + " " + $b1.text;}
      (
        b=IDENT {out = out + ", " + $b.text;}
      )* {out = out + " ->" + " " + $e.text ;}
     )
     {return out;}
  ;